﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SharpDX;

namespace Omega.Game.Framework
{
    [Serializable]
    public class Tile
    {

        protected Vector2 _position;

        public int[ ] TopLeftCorner = new int[ ] { 0 , 0 };
        public int[ ] TopRightCorner = new int[ ] { 16 , 0 };
        public int[ ] ButtomLeftCorner = new int[ ] { 0 , 16 };
        public int[ ] ButtomRightCorner = new int[ ] { 16 , 16 };

        public int TileID = 0;

        public virtual Vector2 Position
        {
            get
            {
                return _position;// +Graphics.Runtime.Camera.ViewPosition;
            }
            set
            {
                _position = value;// +Graphics.Runtime.Camera.ViewPosition;
            }
        }

        public int tilex { get; set; }

        public int tiley { get; set; }

        public String TilesetName { get; set; }

        public Tile( int x , int y , int tilex , int tiley , string tileset , float zDeph )
        {

            Position = new Vector2( x , y );
            this.tilex = tilex;
            this.tiley = tiley;
            this.TilesetName = tileset;
            TopLeftCorner = new int[ ] { 0 , 0 };
            TopRightCorner = new int[ ] { 16 , 0 };
            ButtomLeftCorner = new int[ ] { 0 , 16 };
            ButtomRightCorner = new int[ ] { 16 , 16 };
        }

        public void SetValue( int tilex , int tiley , string tilesetname )
        {
            this.tilex = tilex;
            this.tiley = tiley;
            this.TilesetName = tilesetname;
        }

        public bool IsEqual( Tile oTile )
        {
            return oTile.TilesetName == this.TilesetName && oTile.TileID == TileID;
        }

        public bool IsNotEmpty
        {
            get
            {
                switch ( TileID )
                {
                    case 0:
                        return ( this.tilex >= 0 && tiley >= 0 && TilesetName.Trim( ) != "" );
                    case 1:    
                        return !string.IsNullOrEmpty( this.TilesetName );
                }
                return false; 
            }
        }



    }
}
